<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <link rel="stylesheet" href="../../static/assets/css/zpui.css" />
    <link rel="stylesheet" href="../../static/assets/css/all.css" />
    <script src="../../static/assets/js/page.js"></script>

    <title> 我的提货单 </title>
</head>

<body>
    <div class="page">
        <div class="page-hd">
            <div class="header bor-1px-b">
                <div class="header-left">
                    <a href="javascript:history.go(-1)" class="left-arrow"></a>
                </div>
                <div class="header-title">我的提货单</div>
                <div class="header-right">
                    <a href="#"></a>
                </div>
            </div>
        </div>

        <div class="page-bd">
            <!-- 页面内容-->
            <!--<div class="fs24 text-muted tc mt30">已经到底啦~</div>-->
        </div>
    </div>

    <script src="../../static/assets/js/lib/jquery-2.1.4.js"></script>
    <script src="../../static/assets/js/jquery-weui.min.js"></script>
    <script src="../../static/assets/js/lib/fastclick.js"></script>
    <script>
        let page = 1;
        let html = '';
        let boole = true;
        $(function() {
            FastClick.attach(document.body);
            requestOrder();
            var nScrollHight = 0; //滚动距离总长(注意不是滚动条的长度)
            var nScrollTop = 0; //滚动到的当前位置
            var nDivHight = $(".page-bd").height();
            $(".page-bd").scroll(function() {
                nScrollHight = $(this)[0].scrollHeight;
                nScrollTop = $(this)[0].scrollTop;
                if (nScrollTop + nDivHight >= nScrollHight) {
                    page = page + 1;
                    html = '';
                    requestOrder();
                }
            });
        });

        function requestOrder() {
            $.ajax({
                url: '/shop/api.order/getlist/type/lading/p/'+page+'.html', // 跳转到 action
                type: 'post',
                cache: false,
                headers:{'token': $.cookie('code')},
                            dataType: 'json',
                success: function(res) {
                    if (res.list) {
                        for (let i = 0; i < res.list.length; i++) {
                            html += "        <div class=\"weui-cells card-box\">\n" +
                                "            <div class=\"weui-cell\">\n" +
                                "                <div class=\"weui-cell__bd \">\n" +
                                "                    <div class=\"fs24\">提货单号：" + res.list[i].order_sn + "</div>\n" +
                                "                </div>\n" +
                                "                <div class=\"weui-cell__ft \">\n" +
                                "                    <div class=\"fs24 text-red\">" + res.list[i].ostatus + "</div>\n" +
                                "                </div>\n" +
                                "            </div>\n" +
                                "            <div class=\"weui-cell\">\n" +
                                "                <div class=\"weui-cell__hd mr10\">\n" +
                                "                    <img src=\"" + res.list[i].goodsList[0]['pic'] + "\" class=\"img140\">\n" +
                                "                </div>\n" +
                                "                <div class=\"weui-cell__bd \">\n" +
                                "                    <div class=\"fs28 ellipsisLn1\">" + res.list[i].goodsList[0]['goods_name'] + "</div>\n" +
                                "                    <div class=\"fs26 mt30\" style=\"display: flex;justify-content: space-between;\">\n" +
                                "                        <span>数量：" + res.list[i].goodsList[0]['goods_number'] + "</span>\n" +
                                "                    </div>\n" +
                                "                </div>\n" +
                                "            </div>\n" +
                                "            <div class=\"weui-cell\">\n" +
                                "                <div class=\"weui-cell__bd fs24 text-muted\">\n" +
                                "                    <div>\n" +
                                "                        <span class=\"mr30\">姓名：" + res.list[i]['consignee'] + "</span>\n" +
                                "                        <span>手机号：" + res.list[i]['mobile'] + "</span>\n" +
                                "                    </div>\n" +
                                "                    <div class=\"ellipsisLn1\">\n" +
                                "                        地址：" + res.list[i]['merger_name'] + res.list[i]['address'] + "\n" +
                                "                    </div>\n" +
                                "                </div>\n" +
                                "            </div>\n" +
                                "            <div class=\"weui-cell border-none pt0\" style=\"justify-content: flex-end;margin-top: -0.2rem;\">\n" +
                                "                <a class=\"wlbtn\" href='/shop/order/shippinginfo/order_id/" + res.list[i].order_id + "'>查看物流</a>\n" +
                                "            </div>\n" +
                                "        </div>";
                        }
                    } else {
                        html = "<div class=\"empeyOrder\" style=\"width: 100%;text-align: center;\">\n" +
                            "                <img style=\"width: 100%;\" src=\"/static/mobile/default/images/emptyData.png\" alt=\"\">\n" +
                            "                <span class=\"fs24 text-muted tc mt30\">暂无记录</span>\n" +
                            "            </div>";
                    }

                    if (page != 1) {
                        if (res.list.length < 5 && boole == true) {
                            $('.page-bd').append("<div class=\"fs24 text-muted mt30 tc\">已经到底啦~</div>");
                            boole = false;
                        } else {
                            $('.page-bd').append(html);
                        }
                    } else {
                        $('.page-bd').html(html);
                    }
                }
            });
        }
    </script>

</body>

</html>